package com.miao.teacher.ui;

import com.espeaker.sdk.model.ReviseJson;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.miao.teacher.adapter.FeedbackAdapter;
import com.miao.teacher.adapter.HistoryAdapter;
import com.miao.teacher.controls.LocalRevise;
import com.miao.teacher.utils.DBUtil;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

public class HistoryFragment extends BaseFragment {
	
	private PullToRefreshListView lv = null;
	private HistoryAdapter mAdapter = null;
	
	public static HistoryFragment newInstance() {
		HistoryFragment fragment = new HistoryFragment();
		return fragment;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View view = inflater.inflate(R.layout.layout_history, null);
		lv = (PullToRefreshListView) view.findViewById(R.id.lvPull);
		mAdapter = new HistoryAdapter(getActivity(),LocalRevise.getHistory(new DBUtil(getActivity()).sld));
		lv.setAdapter(mAdapter);
		lv.setOnItemClickListener(new OnItemClickListener(){
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// TODO Auto-generated method stub
				ReviseJson json=(ReviseJson)arg0.getItemAtPosition(arg2);
				HistoryDetailActivity.createInstance(getActivity(),json.xiaofei_id);
			}
		});
		return view;
	}
}
